﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="PictureBrowserController.cs" company="ecblog.codeplex.com">
//   emrecoskun.net - ibrahimatay.com
// </copyright>
// <summary>
//   The picture browser control
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace EcBlog.Areas.Admin.Controllers
{
    using System.IO;

    using Telerik.Web.Mvc.UI;

    /// <summary>
    /// The picture browser control
    /// </summary>
    public class PictureBrowserController : EditorFileBrowserController
    {
        private const string ContentFolderRoot = "~/Content/";

        /// <summary>
        /// Gets the content paths.
        /// </summary>
        public override string[] ContentPaths
        {
            get
            {
                return new[] { this.CreateUserFolder() };
            }
        } 

        private string CreateUserFolder()
        {
            var virtualPath = Path.Combine(ContentFolderRoot, "UserFiles");

            var path = this.Server.MapPath(virtualPath);
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            return virtualPath;
        } 
    }
}